home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
cool
/
ge_cool.lha
/
GE_COOL2.1
/
man
/
oldman3
/
Iterator.3T
< prev
next >
Wrap
Text File
|
1992-06-26
|
3KB
|
92 lines
.TH ITERATOR
.SH NAME
Iterator<Type>\f1 A parameterized iterator class
.SH SYNOPSIS
#include <cool/Iterator.h>
.SH DESCRIPTION
The
\f3Iterator<Type>\f1 class provides an independent mechanism for
maintaining the state associated with the current position of an
instance of a container class. In this manner, multiple iterators over
the same instance of a class can be supported. Each container class
that supports the current position notion has some data structure that
is used to represent the state. This may be as simple as a type long, or
something more involved as with a union of of bit fields or even another
class instance. In addition, each container class has a method to
get/set the current position. Utilization of this method with the
Iterator storage will facilitate storage and retrieval of the current
position.
.PP
The container-specific data structure used to hold the current position
state in all cool container classes will -- by convention -- be named
Class_state,
where
Class
is the name of the container class header file. Thus, a user who
includes Vector.h will declare an
Iterator<Vector>,
and the internal data structure that maintains the state will be of type
Vector_state.
In this manner, the \f3Iterator<Type>\f1 class can be parameterized
over the container class name (ie.
Bit_Set, Vector,
etc.) and allocate
a data slot of the appropriate type by concatenating the
Type
name with
the string
"_state"
all without the user having to know anything about
internal implementation details.
.PP
Each container class has a public method that returns a reference to
this iterator state data structure. The six methods that support
current position functionality in all of the container classes always
work on the current position as maintained in the private data section.
A user can, at any point, change the current position state information
by utilizing this method to get and/or set the current position. One
final note: each state data structure implemented in every container
class must support the assignment of
INVALID
in some manner such that a state with this value (defined in
<cool/misc.h>) will cause an exception if used before set.
.SH Base Classes
None
.SH Friend Classes
None
.SH Constructors
.TP
\f3Iterator<Type> ();\f1
Simple constructor that initializes the container.
.TP
\f3inline Iterator<Type> (Type_state&);\f1
Constructor that takes a reference to the container's current position
state,
Type_state,
and copies the value to the internal slot. This is utilized when
calling the current_position() method of some container class.
.SH Member Functions
\f3inline operator long();\f1
Overloaded operator to convert from the current position state to a
long. This is required by all classes except the
List
and
Tree
classes.
.SH Friend Functions
.TP
None
.SH COPYRIGHT
Copyright (C) 1991 Texas Instruments Incorporated.
Permission is granted to any individual or institution to use, copy, modify,
and distribute this software, provided that this complete copyright and
permission notice is maintained, intact, in all copies and supporting
documentation.
Texas Instruments Incorporated provides this software "as is" without
express or implied warranty.